//package com.netcom.common.message;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.dao.DataAccessException;
//import org.springframework.data.redis.connection.Message;
//import org.springframework.data.redis.connection.MessageListener;
//import org.springframework.data.redis.connection.RedisConnection;
//import org.springframework.data.redis.core.RedisCallback;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.stereotype.Service;
//
///**
// * @author hui
// * @Date 2023/9/21 21:49
// **/
//@Service
//public class MessageSubscriber {
//
//    @Autowired
//    private RedisTemplate<String, Object> redisTemplate;
//
//    public void subscribe(String channel) {
//        redisTemplate.execute(new RedisCallback<String>() {
//            @Override
//            public String doInRedis(RedisConnection connection) throws DataAccessException {
//                connection.subscribe(new MessageListener() {
//                    @Override
//                    public void onMessage(Message message, byte[] bytes) {
//                        System.out.println("Received " + new String(message.getBody()));
//                    }
//                });
//                return null;
//            }
//        });
//    }
//
//}
